package com.ruoyi.wm.controller;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wm.service.IWmApparatusInstorageListService;
import com.ruoyi.wm.service.IWmMedicineInstorageListService;
import com.ruoyi.wm.service.IWmOutStorageService;
import com.ruoyi.wm.vo.WmOutStorageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/wm")
public class WmOutStorageController extends BaseController {
    @Autowired
    private IWmOutStorageService wmOutStorageService;

    @Autowired
    private IWmMedicineInstorageListService wmMedicineInstorageListService;

    @Autowired
    private IWmApparatusInstorageListService wmApparatusInstorageListService;

    @PostMapping("/add")
    @ResponseBody
    public AjaxResult add(@RequestBody String obj_data){
        JSONObject object=JSONObject.parseObject(obj_data);
        WmOutStorageVo outStorageVo = JSONObject.toJavaObject(object,WmOutStorageVo.class);
        AjaxResult result =  toAjax(wmOutStorageService.addOutStorage(outStorageVo));
        int m =  wmMedicineInstorageListService.updateMedicineStock();
        int n =  wmApparatusInstorageListService.updateApparatusStock();
        return result;
    }
}
